package com.kld.simplelauncher;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import androidx.annotation.Nullable;

import com.kld.simplelauncher.app.MoreAppActivity;
import com.kld.simplelauncher.utils.AppUtils;

public class MainActivity extends Activity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mian_layout);
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    public void onBackPressed() {

    }

    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.to_file:
                doRunActivity("com.car.filemanager", "com.car.filemanager.activity.FileDiskActivity");
                break;
            case R.id.to_radio:
                doRunActivity("com.octopus.android.car.apps", "com.octopus.android.car.apps.RadioActivity");
                break;
            case R.id.to_navi:
                doRunActivity("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
                break;
            case R.id.button_bluetooth:
                doRunActivity("com.car.bt", "com.car.bt.activity.MainActivity");
                break;
            case R.id.button_music:
                doRunActivity("com.octopus.android.car.apps", "com.octopus.android.car.apps.audio.activity.MainMusicActivity");
                break;
            case R.id.all_apps_button:
                Intent startAppActivity = new Intent(MainActivity.this, MoreAppActivity.class);
                startActivity(startAppActivity);
                break;
            case R.id.brightness_control:
                AppUtils.doRunActivity(this,"com.car.settings","com.car.settings.SettingsActivity");
                break;
        }
    }

    //add by allen
    private void doRunActivity(String pacageName, String name) {
        try {
            Intent it = new Intent(Intent.ACTION_VIEW);
            it.setClassName(pacageName, name);
            it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(it);
        } catch (Exception e) {
            Log.e("Launcher", e.getMessage());
        }
    }
}
